import Ember from 'ember';
import RSVP from 'rsvp';
import config from 'game-front/config/environment';

export default Ember.Route.extend({
	model(params) {
		var userInfo = this.modelFor("application");
		var apiUrl = config.apiBase + "rankings/current";
		var searchParams = {gameZoneProductId: params.gameZoneProductId};
		if (params["gameId"]) {
			apiUrl = config.apiBase + "rankings/game";
			searchParams = params;
		}
		return RSVP.hash({
			userInfo: userInfo,
			currentRankings: Ember.$.getJSON(apiUrl, Ember.$.extend(searchParams, {userId:userInfo.userId}))
		});
	}
});
